package com.kob.redis.controller;

import com.kob.redis.result.R;
import com.kob.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RedisController {
    @Autowired
    private RedisService redisService;

    @GetMapping("/redis/save/{key}/{value}")
    public R save(@PathVariable("key") String key, @PathVariable("value") String value) {
        return redisService.saveKey(key, value);
    }

    @GetMapping("/redis/delete{key}")
    public R delete(@PathVariable("key") String key) {
        return redisService.removeKey(key);
    }

    @RequestMapping("/redis/update/{key}/{value}")
    public R update(@PathVariable("key") String key, @PathVariable("value") String value) {
        return redisService.updateValue(key, value);
    }

    @GetMapping("/redis/get/{key}")
    public R get(@PathVariable("key") String key) {
        System.out.println(1111111);
        return redisService.getKey(key);
    }
}
